// cpp_oop.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

class Fraction
{
public:
	Fraction();
	Fraction(int d, int n);
	Fraction(int d, int n, int w);
	~Fraction();
	Fraction operator+(Fraction f);
	Fraction operator-(Fraction f);
	Fraction operator*(Fraction f);
	Fraction operator/(Fraction f);
	void display(void);
	void Reduce(void);
	
private:
	int nom;
	int denom;
	int whole;


};

Fraction::Fraction() : nom(1), denom(1){}
Fraction::Fraction(int d, int n) : nom(n), denom(d) , whole(0) {}
Fraction::Fraction(int d, int n, int w) : nom(n), denom(d) , whole(w) {}
Fraction::~Fraction() {}

Fraction Fraction::operator+(Fraction f)
{
	Fraction n;
	n.whole = whole + f.whole;
	n.denom = f.denom * denom;
	n.nom = f.nom*denom + f.denom*nom;
	n.Reduce();
	return n;
}
Fraction Fraction::operator-(Fraction f)
{
	Fraction n;
	n.whole = whole + f.whole;
	n.denom = f.denom * denom;
	n.nom = f.denom*nom - f.nom*denom;
	n.Reduce();
	return n;
}
Fraction Fraction::operator*(Fraction f)
{
	Fraction n;
	n.whole = whole * f.whole;
	n.denom = f.denom * denom;
	n.nom = f.nom*nom;
	n.Reduce();
	return n;
}
Fraction Fraction::operator/(Fraction f)
{
	if (f.denom != 0) return Fraction(f.nom * denom , f.denom * nom );
	else return Fraction(0,0);
}
void Fraction::display(void)
{
	cout << whole << ", " << nom << ", " << denom ;
}
void Fraction::Reduce(void)
{
	if (nom > denom)
	{
		whole += nom / denom;
		nom = nom % denom;		
	}
}

class Point
{
public:
	Point();
	~Point();

private:

};

Point::Point()
{
}

Point::~Point()
{
}

int _tmain(int argc, _TCHAR* argv[])
{
	int j = 0;
	Fraction x = Fraction(5,4);
	Fraction y = Fraction(3,4);

	Fraction z = x+y;
	z.display();
	z.Reduce();
	z.display();
	printf("\n\nHello World! using GIT for version control.");
	for (int i = 0; i < 1000; i++)
	{
		printf(" Value of j: %d\n",j++);
		
	}
	return 0;
}

